package crontask

import (
	"Hypnos-Soundcore/components/config"
	"Hypnos-Soundcore/components/helper"
	"Hypnos-Soundcore/models"
)

// 定时任务一：定时查询DID剩余用量和预订单生成
func (local *LocalController) doDidAmountCheck(ci *config.CronInfo) {

	o, err := helper.NewOrm()
	if err != nil {
		helper.ErrorPrintln("NewOrm：", err)
		return
	}
	err = models.GetDidPrefixOrders(o)
	if err != nil {
		helper.ErrorPrintln(local.Tag, err)
		return
	}
}

// 定时任务二：订单生成&DID信息写入
func (local *LocalController) doWriteOriginalDid(ci *config.CronInfo) {

	o, err := helper.NewOrm()
	if err != nil {
		helper.ErrorPrintln("NewOrm：", err)
		return
	}
	err = models.WriteOriginalDid(o)
	if err != nil {
		helper.ErrorPrintln(local.Tag, err)
		return
	}
}

// 定时任务三：安全验证&DID信息导入
func (local *LocalController) doImportDidOrder(ci *config.CronInfo) {

	o, err := helper.NewOrm()
	if err != nil {
		helper.ErrorPrintln("NewOrm：", err)
		return
	}
	err = models.ImportDidTotal(o)
	if err != nil {
		helper.ErrorPrintln(local.Tag, err)
		return
	}
}
